
package com.bdqn.controller;


import com.bdqn.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class DeptConsumerController {

   //  服务访问路由
    private final String Rest_url_prefix = "http://SPRING-CLOUD-PROVIDER-DEPT";

    @Autowired
    private RestTemplate restTemplate;


    @RequestMapping("/consumer/add")
    public boolean add(@RequestBody Dept dept){
     return  restTemplate.postForObject(Rest_url_prefix+"/dept/adddept",dept,Boolean.class);
    }
    @RequestMapping("/consumer/get/{id}")
    public Dept get(@PathVariable Integer id){
        return  restTemplate.getForObject(Rest_url_prefix+"/dept/getDeptByid/"+id,Dept.class);
    }
    @RequestMapping("/consumer/list")
    public List<Dept> findAll(){
        return  restTemplate.getForObject(Rest_url_prefix+"/dept/findDeptAll",List.class);
    }


}
